package com.hualan.sfzyproject.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzyproject.domain.Courses;
import com.hualan.sfzyproject.domain.Fm;
import com.hualan.sfzyproject.domain.PsyKnowledge;
import com.hualan.sfzyproject.mapper.FmMapper;
import com.hualan.sfzyproject.mapper.PsyKnowledgeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PsyKnowledgeService {
    @Autowired
    private PsyKnowledgeMapper psyKnowledgeMapper;
    public PageInfo<PsyKnowledge> PsyKnowledgePageQuery(Integer page, Integer pageSize) {
        //下行代码告诉MyBatis框架，从第几页开始，每页显示多少条数据，一定要写在查询语句的前面
        PageHelper.startPage(page, pageSize);
        //pagehelp提供啦一个查询拦截器，在查询之前会自动的将查询的sql语句进行拦截
        //在sql语句中添加limit语句
        List<PsyKnowledge> allPsyKnowledge = psyKnowledgeMapper.selectAll();
        //查询操作之后，封装分页数据
        PageInfo<PsyKnowledge> pageInfo = new PageInfo<>(allPsyKnowledge);
        return pageInfo;
    }

    public List<PsyKnowledge> selectByConsultantsId(int id) {
        return psyKnowledgeMapper.selectByConsultantsId(id);
    }

    public int deleteById(int id) {
        return psyKnowledgeMapper.deleteById(id);
    }
    public int insert(PsyKnowledge psyKnowledge) {
        return psyKnowledgeMapper.insert(psyKnowledge);
    }
}

